package lab03.test04;

import java.io.*;

public class Test04 {
    public static void main(String[] args) {


        //文件的拷贝，先读取需要拷贝的文件的内容
        //先找到目标文件的位置（source）和需要复制的到的文件（target）
        String source = "F:\\安装必读.doc";
        String target = "G:\\安装必读.doc";

        //用字节流来读取文件
        FileInputStream fileInputStream = null;
        FileOutputStream fileOutputStream = null;


        try {
            fileInputStream = new FileInputStream(source);
            fileOutputStream = new FileOutputStream(target);

            int data;

            //读一个字节马上就写一个字节
            while ((data = fileInputStream.read()) != -1) {

                fileOutputStream.write(data);
            }
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }finally {
            try {
                fileInputStream.close();
                fileOutputStream.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }

}

